const { contextBridge, ipcRenderer } = require('electron/renderer')

contextBridge.exposeInMainWorld('electronAPI', {
    newBrowserWindow: () => ipcRenderer.invoke('newBrowserWindow'),//创建新的窗口
    setTitle:(value)=>ipcRenderer.send('setTitle',value),//设置窗口标题
    openFile: () => ipcRenderer.invoke('dialogOpenFile'),//选择并获取文件路径
    updateCounter:(callback)=>ipcRenderer.on('update-counter',(event,value)=>callback(value)),//处理更新计数器
    close:()=>ipcRenderer.send('close'),//关闭窗口
    maximize:()=>ipcRenderer.send('maximize'),//窗口最大化
    minimize:()=>ipcRenderer.send('minimize'),//窗口最小化
    setMenu:(value)=>ipcRenderer.send('setMenu',value),//设置菜单
    showContextMenu:()=>ipcRenderer.send('show-context-menu'),//右键菜单
    contextMenuCommand:(callback)=>ipcRenderer.on('context-menu-command',(event,value)=>callback(value)),//右键菜单点击事件
    sendMsg:(value)=>{ipcRenderer.send('sendMsg',value)},
    toMsg:(callback)=>{ipcRenderer.on('toMsg',(event,value)=>{callback(value)})},
    openErr: () => ipcRenderer.invoke('openErr'),//打开错误对话框
    openURL: () => ipcRenderer.invoke('openURL'),//打开URL
    createNotification: () => ipcRenderer.invoke('createNotification'),//打开消息
    copyValue:(value)=>{ipcRenderer.send('copyValue',value)},//复制剪切板
    pasteValue:() => ipcRenderer.invoke('pasteValue'),//粘贴剪切板
    imgValue:() => ipcRenderer.invoke('imgValue')//复制粘贴图片到剪切板
})